<%@ page language="java" import="java.util.*" pageEncoding="utf-8"
	isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="<%=request.getContextPath()%>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/select-ui.min.js"></script>
<script type="text/javascript">
	function chongzhi(a){
		var recharge_money = $(a).val(); 
		if(!/^\d+$/.test(recharge_money)){ 
			alert("请输入正整数");
			$(a).val("");
		}
	}
</script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><e>首页</e></li>
    <li><e>财务管理</e></li>
    <li><e>充值设置</e></li>                                        
    <li><e>设置优惠券面额</e></li>                                        
    </ul>
    </div>
    
    <div class="formbody">
    
    
    <div id="usual1" class="usual"> 
    
    <div class="itab">
  	<ul> 
    <li><a href="#tab1" class="selected" style="font-size:15">设置优惠券面额</a></li> 
    
  	</ul>
    </div> 
    
  	<div id="tab1" class="tabson">
    <ul class="forminfo">
    <li>5元优惠券&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    	<input onchange="chongzhi(this)" name="wu" type="text" class="dfinput" style="width:40px;height:20px;"/>张
    </li>
    <li>10元优惠券&nbsp;&nbsp;&nbsp;
    	<input onchange="chongzhi(this)" name="shi" type="text" class="dfinput" style="width:40px;height:20px;"/>张
    </li>
    <li>20元优惠券&nbsp;&nbsp;&nbsp;
    	<input onchange="chongzhi(this)" name="ershi" type="text" class="dfinput" style="width:40px;height:20px;"/>张
    </li>
    <li>50元优惠券&nbsp;&nbsp;&nbsp;
    	<input onchange="chongzhi(this)" name="wushi" type="text" class="dfinput" style="width:40px;height:20px;"/>张
    </li>
    <li>100元优惠券&nbsp;
    	<input onchange="chongzhi(this)" name="yibai" type="text" class="dfinput" style="width:40px;height:20px;"/>张
    </li>
    <li>总金额
    	<input type="hidden" value="<%=request.getParameter("activity_discount_id")%>"></input>
    	<input type="text" class="dfinput" name="sum" style="width:40px;height:20px;" value="<%=request.getParameter("activity_money")%>"/>元
    </li>
    
    </ul>
    <div><input name="" type="button" class="tijiao" value="提交" style="width:96px; height:35px; line-height:35px; color:#fff; background:red; font-size:14px; font-weight:bold;border-radius: 3px; cursor:pointer;"/>
    <input name="quxiao" type="button" class="cancel" value="取消" /></div>
    </div> 
  </div>
  <script type="text/javascript">
  	$(function(){
  		$("input[name=quxiao]").click(function(){
  			window.location.href="/htx-backer/selectCommontDiscount";
  		})
  		
  		$(".tijiao").click(function(){
  			
  			var wu = $("input[name=wu]").val() * 5;
  			var shi = $("input[name=shi]").val() * 10;
  			var ershi = $("input[name=ershi]").val() * 20;
  			var wushi = $("input[name=wushi]").val() * 50;
  			var yibai = $("input[name=yibai]").val() * 100;
  			var sum = $("input[name=sum]").val();
  			if(sum == null || sum == "" || sum == 0){
  				alert("请先设置总金额");
  				return;
  			}
  			if(wu + shi + ershi + wushi + yibai != sum){
  				alert("优惠券数量与总金额不符");
  				$("input[name=wu]").val("");
  				$("input[name=shi]").val("");
  				$("input[name=ershi]").val("");
  				$("input[name=wushi]").val("");
  				$("input[name=yibai]").val("");
  				return;
  			}
  			$.ajax({
  				type:"get",
  				url:"/htx-backer/updateActivityDiscontNum", 
  				data:{
  					activity_discount_id:$("input[type=hidden]").val(),
  					five_ticket:$("input[name=wu]").val(),
  					ten_ticket:$("input[name=shi]").val(),
  					twenty_ticket:$("input[name=ershi]").val(),
  					fifty_ticket:$("input[name=wushi]").val(),
  					hundred_ticket:$("input[name=yibai]").val(),
  					count_money:$("input[name=sum]").val()
  				},
  				dataType:"json",
  				success:function(data){
  					if(data.flag > 0){
  					 	var btn = confirm("提交成功,点击返回充值设置!")
		   				window.location.href="/htx-backer/selectCommontDiscount";
  					}
  				}
			}) 
  		})
  	})
  </script>
</body>
</html>
